<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>预警查询</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="panel panel-default operation" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-tab">
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-card-body">
                                        <form class="layui-form" action="" lay-filter="info">
                                            <input name="_tabKey" id="_tabKey" hidden>
                                            <input name="_jcajxxuuid" id="_jcajxxuuid" hidden>

                                            <fieldset class="layui-elem-field layui-field-title"
                                                      style="margin-top: 10px;">
                                                <legend>案件信息</legend>
                                            </fieldset>

                                            <div class="layui-form-item">
                                                <label class="layui-form-label">案件名称</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="ajmc" name="ajmc"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>

                                                <label class="layui-form-label">检查项目</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="jcxm" name="jcxm"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">检查人</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="jcry" name="jcry"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">纳税人名称</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="nsrmc" name="nsrmc"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                                <label class="layui-form-label">纳税人识别号</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" id="nsrsbh" name="nsrsbh"
                                                           class="layui-input layui-disabled" disabled="ture">
                                                </div>
                                            </div>

                                            <fieldset class="layui-elem-field layui-field-title"
                                                      style="margin-top: 10px;">
                                                <legend>提醒点</legend>
                                            </fieldset>

                                            <div class="layui-form-item">
                                                <label class="layui-form-label">提醒点</label>
                                                <div class="layui-input-block">
									<textarea rows="3" name="fk" id="fk"
                                              placeholder="" autocomplete="off"
                                              class="layui-textarea layui-disabled"
                                              disabled="ture">金税三期两书未出具</textarea>
                                                </div>
                                            </div>

                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回
                                                    </button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div">
                        <!-- <ul class="layui-tab-title">
                            <li class="layui-this" id="unread" >未读</li>
                            <li id="read" >已读</li>
                        </ul> -->

                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <div class="layui-input-inline">
                                        <input type="text" readonly class="layui-input" id="createTime"
                                               placeholder="创建时间">
                                    </div>

                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input" id="riskMan1" placeholder="风险人员代码">
                                    </div>

                                    <div class="layui-input-inline ">
                                        <button class="layui-btn" onclick="search()" id="search">查询</button>
                                    </div>

                                </div>
                                <table class="layui-table" id="unreadShowTable" lay-filter="unreadShowTable"></table>
                            </div>
                            <div class="layui-tab-item">
                                <div class="layui-form-item">
                                </div>
                                <table class="layui-table" id="readShowTable" lay-filter="readShowTable"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-xs" lay-event="view">详情</a>
</script>

<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var readShowTable;
    var unreadShowTable;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var inspectionMan = "";
    var mold = "";
    var contentdate = null;
    var startTime = null;
    var endTime = null;
    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value, date, endDate) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }
            }
        });


        // 未读
        unreadShowTable = table.render({
            elem: '#unreadShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/risk1/sectionChief' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '提醒编号',
                    hide: true,
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'ajbh',
                    title: '案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 180,
                    field: 'riskMan1',
                    title: '提醒人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 180,
                    field: 'riskRead1',
                    title: '是否已读',
                    sort: true,
                }, {
                    align: 'center',
                    width: 180,
                    field: 'riskName',
                    title: '提醒名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 600,
                    field: 'details',
                    title: '提醒详情',
                    sort: true,
                }, {
                    field: 'createTime', title: '提醒日期', width: 160, align: "center", templet: function (d) {
                        if (!d.createTime) {
                            return '';
                        }
                        return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                    }
                },
            ]],
            toolbar: '#logToolbar'
        });

        // 列操作
        table.on('tool(unreadShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });


        // 列操作
        table.on('tool(unreadShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });


        // 已读
        readShowTable = table.render({
            elem: '#readShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/risk1/readlist2' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '提醒编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'ajbh',
                    title: '案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 180,
                    field: 'riskName',
                    title: '提醒名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 300,
                    field: 'ajmc',
                    title: '案件名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 230,
                    field: 'relevance',
                    title: '关联编号',
                    sort: true,
                }, {
                    field: 'createTime', title: '创建日期', width: 160, align: "center", templet: function (d) {
                        if (!d.createTime) {
                            return '';
                        }
                        return layui.util.toDateString(d.createTime, 'yyyy-MM-dd');
                    }
                },
            ]],
            toolbar: '#logToolbar'
        });

        // 列操作
        table.on('tool(readShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });


        // 列操作
        table.on('tool(readShowTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'view':
                    view(data, "0");
                    break;
            }
        });

        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });

    });

    function search() {
        unreadShowTable.reload({
            where: {
                startTime: startTime,
                endTime: endTime,
                riskMan1: $("#riskMan1").val(),
            },
            page: {
                curr: 1
            }
        });
    };

    function texLength1(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('反馈内容字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    }

    function texLength2(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('推送原因字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    };

    function view(data, id) {
        var _id = data.id;
        $("#_jcajxxuuid").val(data.jcajxxuuid);
        var stateCode = data.stateCode;
        $(".title").html("案件编号：" + data.jcajbh);
        $("#ajmc").val(data.ajmc);
        $("#jcxm").val(data.jcxm);
        $("#nsrmc").val(data.nsrmc);
        $("#nsrsbh").val(data.nsrsbh);
        $("#jcry").val(data.jcry);

        var _fjdz = data.fjdz;
        if (!CoreUtil.isEmpty(_fjdz)) {
            $("#fjdz").val(_fjdz);
            var fjdzArr = _fjdz.split(",");
            var tmp = "<table class='layui-table'><tbody>";
            for (var i = 0; i < fjdzArr.length; i++) {
                var _fjdz = '"' + fjdzArr[i] + '"';
                var _i = i + 1;
                tmp += "<tr><td>附件" + _i + "</td><td>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjyl("
                    + _fjdz + ")'>一键预览</a>"
                    + "<a class='layui-btn layui-btn-xs' onclick='yjfz("
                    + _fjdz + ")'>一键复制</a>" + "</td></tr>";
            }
            tmp += "</tbody></table>";
            $("#fjdzDiv").html(tmp);
        } else {
            $("#fjdzDiv").html("未传附件");
        }
        ;
        // 查询办理流程
        // activityRecordDiv(data.jcajxxuuid);
        $("#pushHearMan21").hide();

        $(".table_div").hide();
        $(".operation").show();

        read(_id);

    };

    function read(_id) {
        var mapArr = {
            'riskRead': '2',
            'id': _id
        };

        CoreUtil.sendPost("/workflow/risk1/read", mapArr,
            function (res) {
                if (res.code == '0') {
                    layer.msg("已读成功！");
                    return false;
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });

    }

    function back() {
        search();
        $(".table_div").show();
        $(".operation").hide();
    }


    function activityRecordDiv(jcajxxuuid) {
        $("#activityRecordDiv").html("");
        var mapArr = {
            relevance: jcajxxuuid
        };

        CoreUtil.sendPost("/workflow/activity/record", mapArr, function (res) {
            if (res.code == '0') {
                var data = res.data;
                if (!CoreUtil.isEmpty(data)) {

                    var tmp = "<table class='layui-table'><tbody><tr>"
                        + "<td>序号</td>"
                        + "<td>处理时间</td>"
                        + "<td>状态</td>"
                        + "<td>处理人</td>"
                        + "<td>内容</td>"
                        + "<td>备注</td>"

                    for (var i in data) {
                        var content = "暂无";
                        if (!CoreUtil.isEmpty(data[i].content)) {
                            content = data[i].content;
                        }

                        tmp += "<tr><td>" + i + "</td>"
                            + "<td>" + data[i].createTime + "</td>"
                            + "<td>" + data[i].stateName + "</td>"
                            + "<td>" + data[i].currentMan + "</td>"
                            + "<td>" + content + "</td>"
                            + "<td>" + data[i].remark + "</td>"

                    }
                    tmp += "</tbody></table>";
                    $("#activityRecordDiv").html(tmp);
                } else {
                    $("#activityRecordDiv").html("暂无流程");
                }

            } else {
                // layer.msg(res.msg);
                return false;
            }
        });

    };

</script>

</body>
</html>